package 最小差;

import java.util.Arrays;

public class Solution
{
    //两个数组之间的最小差值绝对值
    public static int smallestDifference(int[] a, int[] b)
    {
        //排序
        Arrays.parallelSort(a);
        Arrays.parallelSort(b);
        long min=Integer.MAX_VALUE;
        for (int i = 0,j=0; i < a.length&&j < b.length;)
        {
            min=Math.min(min,Math.abs((long) a[i]-b[j]));
            if (a[i]>b[j])
                j++;
            else
                i++;
        }
        return (int)min;

    }

    public static void main(String[] args)
    {
        System.out.println(smallestDifference(new int[]{-2147483648,1}, new int[]{2147483647,0}));
    }
}
